# -*- encoding=utf-8 -*-

from app import app
import configparser

class ConfigReader(object):

    def __init__(self):
        self.path = app.root_path + "/ym.conf";
        self.config = configparser.ConfigParser()
        self.config.read(self.path)

        #mysql
        self.host = self.config.get("mysql", "host")
        self.port = int(self.config.get("mysql", "port"))
        self.schema = self.config.get("mysql", "schema")
        self.username = self.config.get("mysql", "username")
        self.password = self.config.get("mysql", "password")

        #wxapi
        self.base_url = self.config.get("wxapi","base_url")
        self.corpid = self.config.get("wxapi", "corpid")
        self.secret = self.config.get("wxapi", "secret")
        self.send_msg_url = self.config.get("wxapi", "send_msg_url")
        self.get_wechat_id_url = self.config.get("wxapi", "get_wechat_id_url")
        self.feedback_add_receiver = self.config.get("wxapi","feedback_add_receiver")
        self.feedback_shouhou_receiver = self.config.get("wxapi","feedback_shouhou_party")
        self.feedback_anzhuang_receiver = self.config.get("wxapi","feedback_anzhuang_party")

        #MSSQL
        self.mssql_host = self.config.get("MSSQL", "host")
        self.mssql_port = int(self.config.get("MSSQL", "port"))
        self.mssql_schema = self.config.get("MSSQL", "schema")
        self.mssql_username = self.config.get("MSSQL", "username")
        self.mssql_password = self.config.get("MSSQL", "password")

        #sys
        self.domain = self.config.get("sys","domain")

        #admin
        self.admin = self.config.items("admin")
        self.admin_mp = {}
        for kv in self.admin:
            self.admin_mp[kv[0]] = kv[1]

myconfigReader = ConfigReader()

if __name__ == "__main__":
    print(myconfigReader.admin_mp)